<?php $this->Html->addCrumb('Edit Sample Menu');?>
<?php 
$this->Html->scriptStart(array('inline' => false));
echo '
      $(function(){
        $("#ContentAdminSampleMenusForm").TWS_Form( {
          validate : {
          rules : {
            ContentFilePath: {required : true, help : "Select the menu to be uploaded"}
          }
          }});

          $("#deleteLink").click(function(event){
            var $link = $(this);
            $.TWS_Overlay("confirm", 
            { title : "Delete confirmation", message : "Are you sure you want to delete this menu? You will be given the opportunity to upload a new menu.",
              buttons : {ok :{onclick : function () {
                $.TWS_Overlay("hide");
                location.href=$link.attr("href");
                }}}});
            event.preventDefault();
          });
        });
       ';
$this->Html->scriptEnd();
?>
<h1>Sample Menu</h1>
<?php echo $this->Session->flash();?>


<?php if(isset($menu_exists)  && $menu_exists) {
  echo '<p>A sample menu is present on the system. Choose from the following options:</p>';
  echo '<a href="'.Configure::read("App.sampleMenus").'" target="blank">View existing menu</a><br/><br/>';
  echo '<div id="deleteLink">'.$this->Html->link('Delete existing menu and replace it with a new menu.',array('action'=>'sample_menus_delete', 'admin'=>true)).'</div>';
} else {
  //display form to upload menu
  echo '<p>No menu is currently present. Select a menu to be uploaded.</p>';
  echo $this->TWSForm->create( array(
    'inputDefaults' => array(
        'div' => array('class'=>'row')),
        'class'=>'inlineForm',
        'type'=>'file',
        'url'=>array('controller' => 'contents', 'action' => 'sample_menus_add', 'admin'=>true)
    ));
echo $this->TWSForm->input('file_path', array('name'=>'ContentFilePath', 'type'=>'file', 'label'=>'<span class="required">*</span>Menu to upload'));
echo $this->TWSForm->end( array("label"=>"Upload", "class"=>"button"));


}
?>

